package puzzle.projecteuler.p100;

import java.util.HashSet;
import java.util.Set;

import astudy.util.AdvMath;

public class Problem087 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		Integer[] ps2 = AdvMath.primes(8000); 
		Integer[] ps3 = AdvMath.primes(400);
		Integer[] ps4 = AdvMath.primes(100);

		Set<Integer> s = new HashSet<Integer>();
		for (int i = 0; i < ps4.length; i ++) {
			int c = ps4[i];
			c = c*c*c*c;
			for (int j = 0; j < ps3.length; j ++) {
				int b = ps3[j];
				b = b*b*b;
				for (int k = 0; k < ps2.length; k ++) {
					int a = ps2[k];
					a = a*a;
					int m = a + b+ c;
					if (m < 50000000) {
						s.add(m);
					}
				}
			}
		}
		System.out.println(s.size());
	}

}
